#include "StdAfx.h"
#include "DateTime.h"

fuString CDateTime::ToString( int flag /*= DTTS_BOTH */ )
{
    fuString str;
    COleDateTime da(*this);
    if( da.GetYear() < 1900 || flag == DTTS_TIME_ONLY ) // time only
        str = da.Format(_T("%H:%M:%S")).GetString();
    else if((da.GetHour() == 0 && da.GetMinute() == 0 && da.GetSecond() == 0 ) || (flag == DTTS_DATE_ONLY) ) // date only
        str = da.Format(_T("%Y-%m-%d")).GetString();
    else
        str = da.Format(_T("%Y-%m-%d %H:%M:%S")).GetString();
    return str;
}